<!-- resources/templates/register.html -->
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" 
      th:replace="~{layout/default :: html(
          ~{::title},
          ~{::main},
          ~{},
          ~{}
      )}">
<head>
    <title>注册 - 新闻分析系统</title>
</head>
<body>
<main>
    <div class="row justify-content-center mt-5">
        <div class="col-md-6">
            <div class="card shadow-sm">
                <div class="card-header bg-primary text-white text-center">
                    <h4>注册新帐号</h4>
                </div>
                <div class="card-body">
                    <div th:if="${error}" class="alert alert-danger" role="alert" th:text="${error}">
                        错误信息
                    </div>
                    
                    <form th:action="@{/register}" method="post" th:object="${user}">
                        <div class="form-group mb-3">
                            <label for="username">用户名</label>
                            <input type="text" class="form-control" id="username" th:field="*{username}" required>
                            <small class="text-danger" th:if="${#fields.hasErrors(\'username\')}" th:errors="*{username}"></small>
                        </div>
                        <div class="form-group mb-3">
                            <label for="password">密码</label>
                            <input type="password" class="form-control" id="password" th:field="*{password}" required>
                            <small class="text-danger" th:if="${#fields.hasErrors(\'password\')}" th:errors="*{password}"></small>
                        </div>
                        <div class="form-group mb-3">
                            <label for="email">电子邮箱</label>
                            <input type="email" class="form-control" id="email" th:field="*{email}" required>
                            <small class="text-danger" th:if="${#fields.hasErrors(\'email\')}" th:errors="*{email}"></small>
                        </div>
                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-primary">注册</button>
                        </div>
                    </form>
                    <div class="mt-3 text-center">
                        <p>已有账号？ <a th:href="@{/login}">返回登录</a></p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
</body>
</html>
